<?php 
	//error reporting
	ini_set('error_reporting', E_ALL);
	ini_set('display_errors', 1);
	
	//-----------------------------------------------------------------------------------
	include_once("../classes/Database.class.php");
	$db = new Database();
	//-----------------------------------------------------------------------------------
	
	//----------------------------------------
	//GENERO OPTIONS CATEGORIAS
	$data_array = $db->get_data("categorias");	
	$categoria_options = "<option value='' selected='selected'>-- Seleccionar --</option>"; //first value
	foreach($data_array as $record){
		extract($record);
		if(!empty($categoria_options)) $categoria_options.="\n\t\t\t\t\t";
		$categoria_options .= "<option value='$id'>$nombre</option>";
	}
	//----------------------------------------

	//----------------------------------------
	//GENERO DATOS
	extract($_GET);
	if(!empty($categoria)){
		$sql = "select sum(monto) as total from gastos where categoria = $categoria";
		$data_array = $db->runQuery($sql);		
		$total = $data_array[0]["total"];
	}
	//----------------------------------------
		
?>

				<table id="reportTable">
					<tr>
						<td class="rowTitle">Categor&iacute;a:</td>
						<td>
							<select id="category" onchange="viewCategoryReport(this.value)">
								<option value="">-- Seleccionar categor&iacute;a --</option>
								<?php echo $categoria_options; ?>
							</select>							
						</td>
					</tr>
					<?php if(!empty($category)){ ?>
					<tr>						
						<td class="rowTitle">Total:</td>
						<td><?php if(!empty($total)) echo $total; ?></td>
					</tr>
					<?php }//end if ?>
				</table>
			